import sys, os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
xa, ya, xb, yb = map(int, input().split())
xa, xb = min(xa, xb), max(xa, xb)
ya, yb = min(ya, yb), max(ya, yb)
n = int(input())
xyr = [tuple(map(int, input().split())) for _ in range(n)]
ans = 0
x, y = xa, ya
u = [xb - xa, yb - ya]
v = [(1, 0), (0, 1), (-1, 0), (0, -1)]
for i in range(4):
dx, dy = v[i]
for _ in range(u[i % 2]):
f = 0
for x0, y0, r in xyr:
if pow(x0 - x, 2) + pow(y0 - y, 2) <= r * r:
f = 1
break
if not f:
ans += 1
x, y = x + dx, y + dy
print(ans)
#include <bits/stdc++.h>
using namespace std;
int main()
{
int a, b, c, d;
vector<pair<int, int>>general;
cin >> a >> b >> c >> d;
int x1 = min(a,c), y1 = min(b,d), x2 = max(a,c), y2 = max(b,d);
while (1)
{
general.push_back(make_pair(x1,y1));
y1++;
if (y1 > y2)
break;
}
y1 = min(b, d);
while (1)
{
general.push_back(make_pair(x2, y1));
y1++;
if (y1 > y2)
break;
}
x1 = min(a, c), y1 = min(b, d), x2 = max(a, c), y2 = max(b, d);
for (int i = x1 + 1; i < x2; i++)
{
general.push_back(make_pair(i, y1));
general.push_back(make_pair(i, y2));
}
int n;
int x, y, r;
cin >> n;
vector<tuple<int, int, int>>radiator;
for (int i = 0;i<n;i++)
{
cin >> x >> y >> r;
radiator.push_back(make_tuple(x, y, r));
}
float distance = 0;
int result = 0;
int flag = 0;
for (auto i = 0; i < general.size(); i++)
{
for (int j = 0; j < radiator.size();j++)
{
distance = sqrt(pow(abs(general[i].first - get<0>(radiator[j])), 2) + pow(abs(general[i].second - get<1>(radiator[j])), 2));
if (distance <= get<2>(radiator[j]))
{
flag = 1;
break;
}
}
if (flag == 0)
result++;
flag = 0;
}
cout << result << endl;
}
1283B - Candies Division | 1451B - Non-Substring Subsequence |
1408B - Arrays Sum | 1430A - Number of Apartments |
1475A - Odd Divisor | 1454B - Unique Bid Auction |
978C - Letters | 501B - Misha and Changing Handles |
1496A - Split it | 1666L - Labyrinth |
1294B - Collecting Packages | 1642B - Power Walking |
1424M - Ancient Language | 600C - Make Palindrome |
1669D - Colorful Stamp | 1669B - Triple |
1669A - Division | 1669H - Maximal AND |
1669E - 2-Letter Strings | 483A - Counterexample |
3C - Tic-tac-toe | 1669F - Eating Candies |
1323B - Count Subrectangles | 991C - Candies |
1463A - Dungeon | 1671D - Insert a Progression |
1671A - String Building | 1671B - Consecutive Points Segment |
1671C - Dolce Vita | 1669G - Fall Down |